package etnorservice.etnor_service.converter;

import etnorservice.etnor_service.domain.po.BaseArticle;
import etnorservice.etnor_service.domain.vo.ArticleVO;
import lombok.Data;


public class ArticleConverter {

    public static ArticleVO convert(BaseArticle baseArticle) {
        if (baseArticle == null) {
            return null;
        }

        ArticleVO articleVO = new ArticleVO();
        articleVO.setArticleId(baseArticle.getArticleId());
        articleVO.setAuthorId(baseArticle.getAuthorId());
        articleVO.setTitle(baseArticle.getTitle());
        articleVO.setPublishedDate(baseArticle.getPublishedDate());
        articleVO.setViews(baseArticle.getViews());
        articleVO.setContent(baseArticle.getContent());
        articleVO.setSource(baseArticle.getSource());
        articleVO.setBelongsTo(baseArticle.getBelongsTo());
        articleVO.setIsOriginal(baseArticle.getIsOriginal()==1?"ture":"false");
        articleVO.setHasEnglishVersion(baseArticle.getHasEnglishVersion()==1?"ture":"false");
        articleVO.setUpdatedAt(baseArticle.getUpdatedAt());
        articleVO.setLanguage(baseArticle.getLanguage());
        articleVO.setState(baseArticle.getState());
        return articleVO;
    }
}
